package com.bt.lms.ui.page.teaching.supervise.action;

import com.bt.lms.ui.page.teaching.supervise.PageRealTimeClassAdd;
import com.bt.lms.ui.vo.PageSkipInfo;
import javafx.collections.ObservableList;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.layout.Pane;

/**
 * 新增实时课堂事件（实时课堂列表界面的）
 */
public class AddRealTimeClassAction implements EventHandler {

    /**
     * 界面跳转数据
     */
    private final PageSkipInfo pageSkipInfo;

    /**
     * 构建事件
     *
     * @param pageSkipInfo 界面跳转数据
     */
    public AddRealTimeClassAction(PageSkipInfo pageSkipInfo) {
        this.pageSkipInfo = pageSkipInfo;
    }

    /**
     * 事件实现
     * @param event the event which occurred
     */
    @Override
    public void handle(Event event) {

        Pane pane = pageSkipInfo.getPane();
        Integer index = pageSkipInfo.getIndex();

        PageRealTimeClassAdd pageRealTimeClassAdd = new PageRealTimeClassAdd(pageSkipInfo);

        ObservableList<Node> children = pane.getChildren();
        children.set(index,pageRealTimeClassAdd);
    }
}
